public class MyMVC {

public Id selectedAccount { get; set; }
public List<Contact> contactsInformation { get; set; }
   public List<Account> getMyAccounts() {
                       return [SELECT Id, Name, AccountNumber FROM Account];
              }
  
            public void accountClicked() {
                 contactsInformation = [SELECT FirstName, LastName FROM Contact WHERE AccountID = :selectedAccount];
                  }
}